﻿Namespace ImportExport
    ''' <summary>Shows dialog resolving dictionary name conflict during import</summary>
    Public Class frmDictionaryExists
        ''' <summary>Table of shown dictionaries causing conflict</summary>
        Private Table As ĐŘječnikData.DictionaryDataTable
        ''' <summary>CTot</summary>
        ''' <param name="Dics">Table of shown dictionaries causing conflict</param>
        Public Sub New(ByVal Dics As ĐŘječnikData.DictionaryDataTable)

            ' This call is required by the Windows Form Designer.
            InitializeComponent()

            ' Add any initialization after the InitializeComponent() call.

            Table = Dics
            dgwPrev.DataSource = Table
            With Table.Item(0)
                txtE.Text = .NameE
                txtLng1.Text = .Name1
                txtLng2.Text = .Name2
            End With
            Me.DialogResult = Windows.Forms.DialogResult.Cancel
        End Sub

        Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
            Me.Close()
        End Sub
        ''' <summary>Altered name in language 1</summary>
        Public ReadOnly Property Lang1() As String
            Get
                Return txtLng1.Text
            End Get
        End Property
        ''' <summary>altered name in language 2</summary>
        Public ReadOnly Property Lang2() As String
            Get
                Return txtLng2.Text
            End Get
        End Property
        ''' <summary>Altered name in English</summary>
        Public ReadOnly Property LangE() As String
            Get
                Return txtE.Text
            End Get
        End Property
        Private Sub cmdAddDifferent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddDifferent.Click
            For Each row As ĐŘječnikData.DictionaryRow In Table
                If row.Name1 = txtLng1.Text OrElse row.Name2 = txtLng2.Text OrElse row.NameE = txtE.Text OrElse txtE.Text = "" OrElse txtLng1.Text = "" OrElse txtLng2.Text = "" Then
                    MsgBox(My.Resources.YouMustProvideUniqueNames, MsgBoxStyle.Exclamation, My.Resources.Error_)
                    Exit Sub
                End If
            Next row
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End Sub
    End Class
End Namespace